package com.bawei.week.guidance

import android.content.Context
import android.media.audiofx.BassBoost
import android.media.audiofx.BassBoost.OnParameterChangeListener
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.ImageView
import androidx.viewpager.widget.ViewPager.OnPageChangeListener
import com.alibaba.android.arouter.launcher.ARouter
import com.bawei.lib_base.mvvm.BaseViewActivity
import com.bawei.week.R
import com.bawei.week.databinding.ActivityGuidanceBinding
import com.bumptech.glide.Glide
import com.youth.banner.loader.ImageLoader
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class GuidanceActivity : BaseViewActivity<ActivityGuidanceBinding>() {
    val bannerList = mutableListOf<String>()
    override fun initView() {
        bannerList.add("https://img2.baidu.com/it/u=1559167269,2422425888&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1280")
        bannerList.add("https://wx3.sinaimg.cn/mw690/005UJ76vgy1hpg7ssk0ggj30zu25ogx6.jpg")
        bannerList.add("https://img1.baidu.com/it/u=1075242667,2445464562&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=1082")

        binding.banner.setImages(bannerList)
            .setImageLoader(object : ImageLoader(){
                override fun displayImage(context: Context?, path: Any?, imageView: ImageView?) {
                    if (context != null && imageView != null){
                        Glide.with(context).load(path).into(imageView)
                    }
                }
            })
            .start()

        binding.banner.setOnPageChangeListener(object : OnPageChangeListener{
            override fun onPageScrolled(
                position: Int,
                positionOffset: Float,
                positionOffsetPixels: Int
            ) {

            }

            override fun onPageSelected(position: Int) {
                if (position == 2){
                    binding.tvTry.visibility = View.VISIBLE
                }else{
                    binding.tvTry.visibility = View.INVISIBLE
                }
            }

            override fun onPageScrollStateChanged(state: Int) {

            }
        })

        binding.tvTry.setOnClickListener {
            ARouter.getInstance().build("/app/SplashActivity").navigation()
        }
    }

    override fun initData() {

    }
}